package test_package;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15.11.13
 * Time: 14:47
 * To change this template use File | Settings | File Templates.
 */
public class buxfer_com_delete_account {
    WebDriver driver = new FirefoxDriver();



    public void buxter_com_delete_account () {
        driver.get("https://www.buxfer.com");
        driver.findElement(By.id("login_username")).sendKeys("destinygenerated@gmail.com");
        driver.findElement(By.id("login_password")).sendKeys("123123");
        driver.findElement(By.xpath("//a[contains(text(),'Login')]")).click();
        driver.get("https://www.buxfer.com/settings?type=6");
        //driver.findElement(By.xpath("//*[@id=\"the_tab\"]/div[3]/div[2]/div[5]/div/div[4]/div/table/tbody/tr[2]/td/div")).click();
        //driver.findElement(By.xpath("//a[contains(text(),'Yes, delete my account')]")).click();
        WebElement input = driver.findElement(By.xpath("//a[contains(text(),'Yes, delete my account')]"));
        new Actions(driver).moveToElement(input).click().perform();
        driver.findElement(By.name("password")).sendKeys("123123");
        driver.findElement(By.name("reason")).sendKeys("In test purpose");
        //driver.findElement(By.id("overlay-container")).findElement(By.name("elem")).findElement(By.tagName("div")).click();
        //WebElement input2 = driver.findElement(By.className("elem"));
        //new Actions(driver).moveToElement(input2).click().perform();
        driver.findElement(By.xpath("//a[contains(text(),'Delete my account')]")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//a[contains(text(),'Help')]"));
        driver.findElement(By.id("login_username")).sendKeys("destinygenerated@gmail.com");
        driver.findElement(By.id("login_password")).sendKeys("123123");
        driver.findElement(By.xpath("//a[contains(text(),'Login')]")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//a[contains(text(),'Signup now!')]"));
        Assert.assertFalse(driver.getCurrentUrl().contains("home"));

    }

    @AfterTest
    public void buxter_quit () {
        driver.quit();
    }

}
